from common import db
class Category(db.Model):
    # 表的名字:
    __tablename__ = 'category'

    # 表的结构:
    id = db.Column(db.Integer, primary_key=True)
    cate_name = db.Column(db.String(50))
    long_cate_name = db.Column(db.String(150))
    parent_id = db.Column(db.Integer)


class Stock(db.Model):
    # 表的名字:
    __tablename__ = 'stock'

    # 表的结构:
    id = db.Column(db.Integer, primary_key=True)
    stock_code = db.Column(db.String(50))
    stock_name = db.Column(db.String(50))
    category_id = db.Column(db.Integer)

    def to_json(self):
        _dict = self.__dict__
        if "_sa_instance_state" in _dict:
            del _dict["_sa_instance_state"]
        return _dict
